Build Log

The Build Log method of synchronization is used similarly to JSON Compilation Database synchronization, but its application is more generalized as many generic build system logs are suitable. This method of synchronization will work given that:

  • The build log is newline-separated for each source file that was compiled.
  • The lines that contain a path to a source file also contain the Include paths and macro Definitions needed to compile the file.

If your build system does not support the creation of a build log in this format, then, for most IDEs and build systems, a log can be created by using a script that wraps your compiler and outputs all calls to the compiler executable to a log file. The following is an example gcc wrapper using Bash:

#!/bin/bash
echo "$@" >> /home/user/mybuild.log
exec /usr/bin/gcc "$@"

Using this example, all calls to gcc must be redirected to this executable script. Rather than manually altering your project’s build information, a simple method is to name this executable ’gcc’ and place it on the environment variable PATH prior to the actual gcc.

It should be noted that if your project has calls to gcc from multiple directories, this script would collate all relative paths and thus would be unusable without modification. A way to overcome this problem is to convert all relative paths to absolute ones within the bash script:

#!/bin/bash
for var in "$@"
do
if [[ $var = *".c"* ]]; then
        var="${PWD}/${var}" fi
echo -n " ${var}" >> /home/user/mybuild.log
done echo >> /home/user/mybuild.log exec /usr/bin/gcc "$@"

When the Optional Working Directory field is left unspecified, the paths within the build log are considered absolute or relative to the project root directory.